<?php
namespace Patrol\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index($securityData){
        $Model = M('user');
        $user = $securityData->userAccount;
        $pwd= encrypt($securityData->password);
        $sult = $Model->where("userAccount='%s' and password='%s' ",$user,$pwd)->find();
        if($sult){
            $sqldata['timeStamp'] = $securityData->timeStamp;
            $sqldata['info'] = $securityData->info->imei;
            $Model->where($data)->save($sqldata);
            $token = tokenEncrypt($user);
            $arr = array ('result'=>true,'message'=>'登陆成功','name'=>$sult['name'],'token'=>$token);
            //记录token
            \Tool\Token::setToken($arr['token'], $user);
            //返回数据
            echo json_encode($arr);
             
        }else{
            $arr = array ('result'=>false,'message'=>'登陆失败');
            echo json_encode($arr);
        }
    }
}